﻿
@{
    ViewData["Title"] = "OrgEdit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model RTW.Models.TOrganization
@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .input-group-addon {
            width: 80px;
        }

        .input-group {
            margin-bottom: 15px;
            text-align: center;
            width: 100%;
        }

        .text-left label {
            font-weight: normal;
            margin-right: 8px;
            margin-left: 2px;
        }

        .checkbox label, .radio label {
            padding-left: 0px;
        }
    </style>
}
    <form id="form1" asp-action="OrgEdit">
        <div id="dContent">
            <div class="input-group">
                <span class="input-group-addon">所属机构</span>
                @*<asp:TextBox ID="txtDMName" runat="server" CssClass="form-control" ReadOnly="true"></asp:TextBox>*@
                @Html.TextBoxFor(m => m.PDM.DMName, new { @class = "form-control", ReadOnly = "true", Enabled = "false" })
            </div>
            <div class="input-group">
                <span class="input-group-addon">属性</span>
                @*<asp:DropDownList ID="ddlOrgDepartment" runat="server" CssClass="form-control" dataType="null" Msg="请选择属性!">
                    <asp:ListItem Value="" Text=""></asp:ListItem>
                    <asp:ListItem Value="内设机构" Text="内设机构" Selected="True"></asp:ListItem>
                    <asp:ListItem Value="其他" Text="其他"></asp:ListItem>
                </asp:DropDownList>*@
                @Html.DropDownListFor(m=>m.NewOrgDepartment, new SelectList(
                                          new List<object>{
                                               new { value = "内设机构" , text = "内设机构" },
                                               new { value = "其他" , text = "其他" }
                                            },
                                          "value",
                                          "text"
                                        ), new { @class= "form-control" ,dataType = "null", Msg = "请选择属性!" })

            </div>
            <div class="input-group">
                <span class="input-group-addon">名称</span>
                @*<asp:TextBox ID="txtOrgName" runat="server" CssClass="form-control" dataType="null" Msg="名称不能为空!"></asp:TextBox>*@
                @Html.TextBoxFor(m => m.OrgName, new { @class = "form-control", dataType = "null", Msg = "名称不能为空!" })
            </div>
            <div class="input-group">
                <span class="input-group-addon">代码</span>
                @*<asp:TextBox ID="txtOrgNo" runat="server" CssClass="form-control" dataType="null" Msg="编码不能为空!"></asp:TextBox>*@
                @Html.TextBoxFor(m => m.OrgNo, new { @class = "form-control", dataType = "null", Msg = "编码不能为空!" })
            </div>
            <div class="input-group">
                <span class="input-group-addon">拼音码</span>
                <asp:TextBox ID="txtPinYinNo" runat="server" CssClass="form-control"></asp:TextBox>
                @Html.TextBoxFor(m => m.PinYinNo, new { @class = "form-control" })
            </div>
            @*<div class="input-group">
                <span class="input-group-addon">其他码</span>
                <asp:TextBox ID="txtOtherNo" runat="server" CssClass="form-control"></asp:TextBox>
                @Html.TextBoxFor(m => m.OtherNo, new { @class = "form-control" })
            </div>*@
            <div class="input-group">
                <span class="input-group-addon">备注</span>
                @*<asp:TextBox ID="txtRemark" runat="server" CssClass="form-control" TextMode="MultiLine" Height="65"></asp:TextBox>*@
                @Html.TextBoxFor(m => m.Remark, new { @class = "form-control", TextMode = "MultiLine", Height = "65" })
            </div>
            <div class="input-group">
                <span class="input-group-addon">状态</span>
                <div class="form-control text-left">
                    <div class="checkbox i-checks" style="float: left; margin-right: 5px; width: 150px; text-align: left; margin-top: 5px;">
                        @Html.CheckBoxFor(m => m.StateValue)
                        <label style="padding-left: 0px;">
                            停用
                        </label>
                    </div>
                </div>
            </div>
            <div class="input-group">
                <span class="input-group-addon">索引</span>
                @*<asp:TextBox ID="txtIndex" runat="server" CssClass="form-control" dataType="null,zzs" Msg="索引格式不正确!"></asp:TextBox>*@
                @Html.TextBoxFor(m => m.Flag1, new { @class = "form-control", dataType = "null,zzs", Msg = "索引格式不正确!" })
            </div>
        </div>
        <div class="zui-footer">
            @*<asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary btn-sm" Text="保存" OnClick="btnSave_Click" OnClientClick="return verfic('tip', '#dContent');" />*@
            <button id="btnSave" class="btn btn-primary btn-sm" type="submit">保存</button>
            <button class="btn btn-default btn-sm" type="button" onclick="closePage()">关闭</button>
        </div>
        @Html.HiddenFor(m => m.ID)
        @Html.HiddenFor(m => m.AddTime)
        @Html.HiddenFor(m => m.Flag2)
        @Html.HiddenFor(m => m.OrgDepartment)
    </form>
@section scripts{
    <script src="~/lib/jquery/jquery.min.js"></script>
    @*<script src="~/js/jquery.min.js?v=2.1.4"></script>*@
    <script src="~/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="~/js/My97DatePicker/WdatePicker.js"></script>
    <script src="~/js/plugins/layer/layer.min.js"></script>
    <script src="~/js/plugins/iCheck/icheck.min.js"></script>

    <script src="~/lib/jquery.form/jquery.form.min.js"></script>
    <script src="~/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/js/plugins/validate/additional-methods.min.js"></script>
    <script src="~/js/plugins/validate/messages_zh.min.js"></script>
    <script src="~/js/verification.js"></script>
    <script src="~/js/zuiCode.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".i-checks").iCheck({
                checkboxClass: "icheckbox_square-green",
                radioClass: "iradio_square-green"
            })
            formSubmit();
        })

            //提交

        function formSubmit() {
                        $("#form1").validate({
                            rules: {
                                OrgName: {
                                    required: true
                                },
                                OrgNo: {
                                    required: true
                                },
                                OrgDepartment: {
                                    required: true
                                },
                                Flag1: {
                                    digits: true
                                }
                            },
                            errorPlacement: function (error, element) {
                                //错误消息不为空，提示Msg消息或默认消息
                                if (error[0].textContent != "") {
                                    if (error[0].textContent != undefined) {
                                        let msg = element.attr("Msg") ? element.attr("Msg") : error.textContent;
                                        showTip(msg, 2);
                                    }
                                }
                            },
                            onkeyup: false,
                            focusCleanup: true,
                            success: "valid",

                            submitHandler: function (form) {
                                //return verfic('tip', '#dContent');
                                //var fRankName = $("select[name='fRankId']").find("option:selected").text();
                                //var fState = $("input[name='fState']").is(':checked');
                                $(form).ajaxSubmit({
                                    type: "POST",
                                    cache: false,
                                    //data: { fRankName: fRankName, fState: fState },
                                    dataType: "json",
                                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                                        if (XMLHttpRequest.status != 200) {
                                            showTip(errorThrown, 2);
                                        }
                                    },
                                    success: function (result) {

                                        var state = result.success;
                                        var message = result.msg;
                                        if (state) {
                                            showTip(message, 1, 2);
                                        } else {
                                            showTip(message, 2);
                                        }

                                    }
                                });
                            }
                        });
                    }



    </script>
}
